
layui.use(['jquery','element','laytpl','form'], function() {
    var $ = layui.jquery,
        element = layui.element,
        form = layui.form,
        response = layui.response,
        laytpl = layui.laytpl;

    $(function () {
        form.on('submit(*)', function(data){
            console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}\
            var registerUserBO = data.field
            $.ajax({
                type: "POST",
                url: path +"/user/login",
                async:false,
                data: JSON.stringify(registerUserBO),
                contentType: 'application/json',
                dataType: "json",
                success: function (res) {
                    console.info(res);
                    var data = res.data;
                    localStorage.setItem("token", data.userUniqueToken);
                    localStorage.setItem("user", data);
                    window.location = path + "/views/index.html";
                },error: function(e){
                    console.info(e);
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });
});